home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 12896 < prev    next >
Encoding:
Text File  |  1996-08-05  |  761 b   |  39 lines

  1. Path: slip-2-7.ots.utexas.edu!user
  2. From: ferry299@cs.utexas.edu (Ferry Sutanto)
  3. Newsgroups: comp.lang.c++
  4. Subject: struct member
  5. Date: Fri, 22 Mar 1996 01:04:41 -0600
  6. Organization: The University of Texas Austin
  7. Message-ID: <ferry299-2203960104410001@slip-2-7.ots.utexas.edu>
  8. NNTP-Posting-Host: slip-2-7.ots.utexas.edu
  9.  
  10. Hi,
  11.  
  12. I need some help here. :-). If I have an object in a struct as its member,
  13. can I initialize it with initializer list ? If so, how ? For example,
  14.  
  15. class A
  16. {
  17. public:
  18.    A() { };
  19.    A( int ) { };
  20. }
  21.  
  22. struct mystruct{
  23.    A memberA;
  24.    int i 
  25. };
  26.  
  27. void main( void )
  28. {
  29.    A a1;
  30.    struct mystruct st = { a1, 1 }; //<======can I do this ? 
  31.    
  32.    struct mystruct st2 = { a(1), 1 }; //<=======how about this ?
  33. };
  34.  
  35.  
  36. Thank you before hand.
  37.  
  38. -Ferry
  39.